; Tabla de syscalls
;
%ifdef __KERNEL__

%include "isr-def.mac"

extern syscall_table
extern syscall_max

syscal_ret:
	dd 0x0

global syscall_isr
syscall_isr:
	;desactivo las int
	;push ds
	;push es
	;push fs
	;push gs
	;xchg bx, bx
	PUSHALL
	
	push eax
	mov eax, 0x10
	mov ds, ax
	mov es, ax
	mov fs, ax
	mov gs, ax
	pop eax
	
	cmp eax, [syscall_max]
	ja syscall_error
	
	push edx
	push ecx
	mov eax, [ syscall_table + eax * 4 ]
	call eax
	mov [syscal_ret], eax
	
	add esp, 8
syscall_end:
	;pop gs
	;pop fs
	;pop es
	;pop ds
	POPALL  
	mov eax, [syscal_ret]
	iret
	
syscall_error:
	mov eax, -1
	jmp syscall_end


%endif
